package com.example.basicsecurity.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;


/**
 * @author 罗俊华
 * @date 2021/10/9 - 11:19 上午
 */
@Slf4j
@Order(SecurityProperties.BASIC_AUTH_ORDER - 10)
//@EnableWebSecurity
@EnableOAuth2Sso
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {




    /**
     * 新增了一条spring security 的过滤器链，并且其优先于 fallback 过滤器链执行
     * fallback 的过滤器链的优先级为 @Order(SecurityProperties.BASIC_AUTH_ORDER)
     *
     * @param http
     * @throws Exception
     */
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // 这里定义的拦截顺序非常重要
        http.authorizeRequests()
                .anyRequest()
                .authenticated();

    }
}
